package cn.xiuxius.embedded.runconfig;

import com.intellij.execution.configurations.RunConfigurationOptions;
import com.intellij.openapi.components.StoredProperty;

public class EasySTCRunConfigurationOptions extends RunConfigurationOptions {

  private final StoredProperty<String> taskName = string(EasySTCTask.BUILD.name()).provideDelegate(this, "task");
  private final StoredProperty<Boolean> buildClean = property(false).provideDelegate(this, "buildClean");
  private final StoredProperty<String> flushPort = string("AUTO").provideDelegate(this, "flushPort");
  private final StoredProperty<String> comPort = string("").provideDelegate(this, "comPort");
  private final StoredProperty<String> comRate = string("").provideDelegate(this, "comRate");

  public EasySTCTask getTask() {
    try {
      return EasySTCTask.valueOf(taskName.getValue(this));
    } catch (IllegalArgumentException e) {
      return EasySTCTask.RUN;
    }
  }


  public void setTask(EasySTCTask task) {
    taskName.setValue(this, task.name());
  }

  public boolean isBuildClean() {
    return buildClean.getValue(this);
  }

  public void setBuildClean(boolean value) {
    buildClean.setValue(this, value);
  }

  public String getFlushPort() {
    return flushPort.getValue(this);
  }

  public void setFlushPort(String value) {
    flushPort.setValue(this, value);
  }

  public String getComPort() {
    return comPort.getValue(this);
  }

  public void setComPort(String value) {
    comPort.setValue(this, value);
  }

  public String getComRate() {
    return comRate.getValue(this);
  }

  public void setComRate(String value) {
    comRate.setValue(this, value);
  }
}
